package com.huilink.webmail.util.client.widgets;

import com.google.gwt.i18n.client.ConstantsWithLookup;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;


/**
 * The top panel, which contains the 'welcome' message and various links.
 */
public class HelpButton extends Composite implements ClickListener
{
	private ConstantsWithLookup constants;
	private ButtonSettings settings;
    
    public HelpButton(ConstantsWithLookup constants, ButtonSettings settings)
    {
    	this.constants = constants;
    	this.settings = settings;
        
        HorizontalPanel outer = new HorizontalPanel();

        String btnIcon = settings.getBtnIcon();
        ImageButton helpBtn = new ImageButton(btnIcon,btnIcon,53,22);//16
        //helpBtn.setTitle(helpKey);
        helpBtn.setText("");
        helpBtn.addClickListener(this);
        outer.add(helpBtn);
        
        outer.setHorizontalAlignment(HorizontalPanel.ALIGN_RIGHT);

        initWidget(outer);
    }
    public void set(ButtonSettings settings){
    	this.settings = settings;
    }


    public void onClick(Widget sender)
    {	
    	//String title = sender.getTitle();
    	HelpPanel dlg = new HelpPanel(constants, settings);
        int left = (Window.getClientWidth() - 512) / 2;
        int top = (Window.getClientHeight() - 256) / 2;
        dlg.setPopupPosition(left, top);
        dlg.show();
    }

}
